<template>
  <div class="app-container">
    <el-form-item label="请选择Excel">
      <el-upload
        ref="uploadRef"
        class="upload-demo"
        :action="uploadUrl + '/serviceedu/edu-subject/addSubjectExcel'"
        :auto-upload="false"
      >
        <template #trigger>
          <el-button type="primary">选取文件</el-button>
        </template>

        <el-button class="ml-3" style="margin-left: 20px;" type="success" @click="submitUpload">
         上传至服务器
        </el-button>

        <template #tip>
          <div class="el-upload__tip">
            PG/PNG 文件的文件大小小于500KB
          </div>
        </template>
      </el-upload>
    </el-form-item>
  </div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import type { UploadInstance } from "element-plus";
const uploadUrl = import.meta.env.VITE_URL
const uploadRef = ref<UploadInstance>();

const submitUpload = () => {
  uploadRef.value!.submit();
};
</script>

<style scoped></style>